#include<stdio.h>

void main()
{
int a,c,d;
int i,*q;

	printf("enter the size of array:");
	scanf(" %d",&a);
int b[a];
//q=&b	
	printf(" \n enter the elemnts of array \n\n");
	for(i=0;i<a;i++)
	{
		printf(" enter :");
		scanf(" %d",&b[i]);
	}
	
	do
	{
		printf("Choose the operation:");
		printf("1.Reverse \n 2.Count \n 3. Pop \n 4. Index \n 5.Remove \n 6.Append \n 7.Sort \n ");
		scanf(" %d",&c);
		switch(c)
		{
			case 1: rev(a,b);break;
			case 2: count(a,b);break;
			case 3: pop(a,b);break;
			case 4: indval(a,b);break;
			//case 5: remove(a,b);break;
			//case 6: append(a,b);break;
			case 7: sort(a,b);break;
		}
		
	}
	while(d!=0);

}

rev(int a,int *b)
{
	int k,l,t,temp;

	t=a/2;

	for(k=0;k<t;k++)
	{
		temp=b[k];
		b[k]=b[a-k];
		b[a-k]=temp;
	}

	for(l=1;l!=a+1;l++)
	{
		printf(" %d",b[l]);
	}

}

count(int a,int *b)
{
	int f,j;
	int c=0;
	printf("enter the no. to count:");
	scanf(" %d",&f);

	for(j=0;j<a;j++)
	{
		if(b[j]==f)
			c+=1;
		

	}
	printf(" no. of %d is : %d",f,c);
}

pop(int a, int *b)
{
	int c;
	int d[a-1];
	int j,k;


	printf(" \n enter the index value:");
	scanf(" %d",&c);

	printf("\n");

	if(c<a)
	{
		for(j=c;j<a-1;j++)
		{
			b[j]=b[j+1];
		}

		printf("the new list is:");

		for(k=0;k<a-1;k++)
		{
			printf(" %d ",b[k]);
		}

	}
	else if(c==111)
	{
		
		for(j=0;j<a-1;j++)
		{
			d[j]=b[j];
		}
		printf("the new list is:");

		for(k=0;k<a-1;k++)
		{
			printf(" %d ",d[k]);
		}
	}
	else
	{
		printf("no such index value");
	}
	printf("\n");
}

indval(int a, int *b)
{
	int c;
	printf("\n\n enter the index value :");
	scanf(" %d",&c);

	if(c<=a)
	{
		printf("\n the value is : %d ",b[c]);
	}
	else
	{
		printf("the index is invailid");
	}
}

remove(int a, int *b)
{
	int c,i,j;
	printf("enter the no. to remove");
	scanf(" %d",c);

	for(i=0;i<a;i++)
	{
		if(c==b[i])
		{
			for(j=c;j<a;j++)
			{
				
			}
		}
	}


}

sort(int a,int *b)
{
	int i,j,t;

	for(i=0;i<=a-1;i++)
	{
		for(j=i+1;j<=a;j++)
		{
			if(b[i]<b[j])
			{
				t=b[i];
				b[i]=b[j];
				b[j]=t;
			}
		}
	}

	for(i=0;i<a;a++)
	{
		printf(" %d",b[i]);
	}

}
